<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/init.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<jsp:include page="/WEB-INF/jsp/common/common.jsp" />
<jsp:include page="/WEB-INF/jsp_lib/validate.jsp" />
<link rel="stylesheet"
	href="${path}/style_lib/zTree_v3/css/zTreeStyle/zTreeStyle.css"
	type="text/css"></link>
<script type="text/javascript"
	src="${path}/style_lib/zTree_v3/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript"
	src="${path}/style_lib/zTree_v3/js/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript"
	src="${path}/style_lib/zTree_v3/js/jquery.ztree.excheck-3.5.js"></script>
<script type="text/javascript">
	function onCheck(e, treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("treeDemo");
		nodes = zTree.getCheckedNodes(true);
		v = "";
		for (var i = 0, l = nodes.length; i < l; i++) {
			v += nodes[i].code + ",";
		}
		if (v.length > 0)
			v = v.substring(0, v.length - 1);
		var check_note = $("input[name='auth_codes']");
		check_note.attr("value", v);
	};

	var setting = {
		edit : {
			enable : false
		},
		view : {
			fontCss : {
				"margin" : "2px"
			}
		},
		check : {
			enable : true,
			chkStyle : "checkbox"
		},
		data : {
			simpleData : {
				enable : true,
				idKey : 'code',
				pIdKey : 'up_code',
				rootPId : 'root'
			}
		},
		callback : {
			onCheck : onCheck
		}
	};

	var zNodes = $.parseJSON('${menuJson}');
	var zTreeObj;
	$(function() {
		$.each(zNodes, function(i, n) {
			zNodes[i].iconOpen = "${path}/style_lib/zTree_v3/icon/open.jpg";
			zNodes[i].iconClose = "${path}/style_lib/zTree_v3/icon/close.jpg";
			zNodes[i].icon = "${path}/style_lib/zTree_v3/icon/open.jpg";

			zNodes[i].url_new = zNodes[i].url;
			zNodes[i].url = "";
		});

		zTreeObj = $.fn.zTree.init($("#treeDemo"), setting, zNodes);

		var node = zTreeObj.getNodeByParam("code", "train_process");

	});

	function mySubmit() {
		var msg = "";
		if ($("input[name='name']").val() == "") {
			msg = "角色名不能为空!";
			ohSnap(msg, "warning");
			return;
		}
		if ($("input[name='sort']").val() == "") {
			msg = "排序值不能为空!";
			ohSnap(msg, "warning");
			return;
		}
		if ($("input[name='auth_super']:checked").val() == null) {
			msg = "适用机构类型不能为空!";
			ohSnap(msg, "warning");
			return;
		}
		if ($("input[name='auth_codes']").val() == "") {
			msg = "权限不能为空!";
			ohSnap(msg, "warning");
			return;
		}
		$("#form1").submit();
	}
</script>
</head>
<body>
	<jsp:include page="/WEB-INF/jsp_lib/tip.jsp" />
	<!-- 内容 -->
	<div>
		<form method="post" action="${path}/ix/role/add.htm" id="form1">
			<input type="hidden" name="auth_codes" value="" />
			<h2>
				<div>新建角色</div>

			</h2>
			<table width="100%" class="lindex">
				<tr>
					<th align="right">角色名称：</th>
					<td align="left" colspan="3"><input name="name" type="text"
						maxlength="100" /></td>
				</tr>
				<tr>
					<th align="right">角色描述：</th>
					<td align="left" colspan="3"><input name="note" type="text"
						maxlength="100" /></td>
				</tr>
				<tr>
					<th align="right">排序值：</th>
					<td align="left" colspan="3"><input name="sort" type="text"
						maxlength="11" onkeyup="this.value=this.value.replace(/\D/g,'')" />
					</td>
				</tr>

				<tr>
					<th align="right">适用机构类型：</th>
					<td align="left" colspan="3"><input name="auth_super"
						type="checkbox" maxlength="11" value="4" />网点&nbsp; <input
						name="auth_super" type="checkbox" maxlength="11" value="3" />支行&nbsp;
						<input name="auth_super" type="checkbox" maxlength="11" value="2" />二极分行&nbsp;
						<input name="auth_super" type="checkbox" maxlength="11" value="1" />一级分行&nbsp;
						<input name="auth_super" type="checkbox" maxlength="11" value="5" />总行&nbsp;
					</td>
				</tr>

			</table>
			<div>&nbsp;</div>
			<div>
				<div>
					<div style="text-align: left;margin-left: 8%;font-weight: bold;">权限类型</div>
					<br />
					<div class="zTreeDemoBackground left" style="margin-left: 15%;">
						<ul id="treeDemo" class="ztree"></ul>
					</div>
				</div>

			</div>

			<div class="options">
				<a href="javascript:mySubmit();" class="asave"> 【保存】 </a> <a
					href="javascript:goBack();" class="asave"> 【返回】 </a>
			</div>
		</form>

	</div>
</body>
</html>